package com.blue.common.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    //注入系统错误日志队列
    @Bean
    Queue errorLogsQueue() {
        return new Queue("errorLogsQueue");
    }

    //注入系统错误日志交换机
    @Bean
    DirectExchange errorLogsExchange() {
        return new DirectExchange("errorLogsExchange", true, false);
    }

    //将队列和交换机进行绑定
    @Bean
    Binding errorLogsBinding() {
        return BindingBuilder.bind(errorLogsQueue()).to(errorLogsExchange()).with("errorLogsKey");
    }

    //注入数据同步队列
    @Bean
    Queue dataSyncQueue() {
        return new Queue("dataSyncQueue");
    }

    //注入数据同步交换机
    @Bean
    DirectExchange dataSyncExchange() {
        return new DirectExchange("dataSyncExchange", true, false);
    }

    //将队列和交换机进行绑定
    @Bean
    Binding dataSyncBinding() {
        return BindingBuilder.bind(dataSyncQueue()).to(dataSyncExchange()).with("dataSyncKey");
    }

    //注入系统操作日志队列
    @Bean
    Queue operationLogsQueue() {
        return new Queue("operationLogsQueue");
    }

    //注入系统操作日志交换机
    @Bean
    DirectExchange operationLogsExchange() {
        return new DirectExchange("operationLogsExchange", true, false);
    }

    //将队列和交换机进行绑定
    @Bean
    Binding operationLogsBinding() {
        return BindingBuilder.bind(operationLogsQueue()).to(operationLogsExchange()).with("operationLogsKey");
    }

    //注入AI聊天队列
    @Bean
    Queue chatQueue() {
        return new Queue("chatQueue");
    }

    //注入AI聊天交换机
    @Bean
    DirectExchange chatExchange() {
        return new DirectExchange("chatExchange", true, false);
    }

    //将队列和交换机进行绑定
    @Bean
    Binding chatBinding() {
        return BindingBuilder.bind(chatQueue()).to(chatExchange()).with("chatKey");
    }
}
